<template>
  <el-config-provider :locale="lang">
    <router-view />
  </el-config-provider>
</template>

<script setup>
import { useTheme } from '@/hooks/useTheme'
import { useLocaleStore, usePermissionStore, useTagsViewStore } from '@/store'
import { $t, elementLocale } from '@/languages/index'

const { initTheme } = useTheme()
const localeStore = useLocaleStore()
const permissionStore = usePermissionStore()
const tagsViewStore = useTagsViewStore()
const lang = computed(() => elementLocale[localeStore.locale])

const initializeApp = async () => {
  /** 初始化主题 */
  initTheme()
  /** 初始化语言包 */
  // await localeStore.setInitLanguagesAction()
  /** 初始化语言 */
  const language = localStorage.getItem('language') || 'en-US'
  await localeStore.setLocaleAction(language)
  /** 初始化标签标题 */
  await tagsViewStore.setI18nKeyTagsView()
  /** 初始化路由标题 */
  await permissionStore.setRouterTitle(permissionStore.routes, $t)
}
initializeApp()
</script>
